home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / egamouse.zip / EGATEST.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  3KB  |  115 lines

  1. program EgaTest;
  2.  
  3. uses
  4.   Crt, Graph, EgaMouse;
  5.  
  6. var
  7.    grDriver, grMode: integer;
  8.    X,Y,Stat       : Word;
  9.    Mouse: boolean;
  10.  
  11. procedure TestMouse;
  12.  
  13. var
  14.   Ch               : Char;
  15.   X,Y,Stat,I       : Word;
  16.   S1, S2, S3       : String;
  17.  
  18. begin {TestMouse}
  19.  
  20.   if not Mouse_Installed then
  21.   begin
  22.     OutTextXY(10,10,'Mouse not installed');  { if mouse hardware and }
  23.     Halt                                     { software not found, then abort }
  24.   end;
  25.  
  26.  
  27.   OutTextXY(240,15,'EGAMouse Demo');
  28.  
  29.   Rectangle(130,70,270,160);
  30.   SetFillStyle(1,blue);
  31.   FloodFill(131,71,white);
  32.   OutTextXY(160,55,'Hour Glass');
  33.  
  34.   Rectangle(320,70,460,160);
  35.   SetFillStyle(1,green);
  36.   FloodFill(321,71,white);
  37.   OutTextXY(340,55,'Pointing Hand');
  38.  
  39.   Rectangle(130,190,270,280);
  40.   SetFillStyle(1,red);
  41.   FloodFill(131,191,white);
  42.   OutTextXY(165,175,'Check Mark');
  43.  
  44.   Rectangle(320,190,460,280);
  45.   SetFillStyle(1,magenta);
  46.   FloodFill(321,191,white);
  47.   OutTextXY(337,175,'Diagonal Cross');
  48.  
  49.   TextColor(white);
  50.  
  51.   GotoXY(28,23);
  52.   Write('Mouse is at');
  53.   GotoXY(26,24);
  54.   Write('Button(s) Pressed:');
  55.  
  56.   SetMousePosition(300,175);    { Set Mouse position to screen center }
  57.   ShowMouse;                    { Display standard Mouse cursor }
  58.  
  59.  
  60.   repeat  { Loop until key pressed }
  61.  
  62.     Stat := MousePosition(X,Y);
  63.     if ((X>130) and (X<270)) and ((Y>70) and (Y<160)) then
  64.        CursorShape(HourGlass)
  65.     else if ((X>320) and (X<460)) and ((Y>70) and (Y<160)) then
  66.        CursorShape(PointingHand)
  67.     else if ((X>130) and (X<270)) and ((Y>190) and (Y<280)) then
  68.        CursorShape(CheckMark)
  69.     else if ((X>320) and (X<460)) and ((Y>190) and (Y<280)) then
  70.        CursorShape(DiagCross)
  71.     else
  72.        CursorShape(Standard);
  73.  
  74.     Str(X,S1);
  75.     Str(Y,S2);
  76.     Str(Stat,S3);
  77.  
  78.     GotoXY(40,23);
  79.     Write(S1+', '+S2:8);    { write Mouse X and Y coordinates }
  80.  
  81.     GotoXY(45,24);
  82.     case Stat of
  83.        0: S3 := 'none ';
  84.        1: S3 := 'left ';
  85.        2: S3 := 'right';
  86.        3: S3 := 'both '
  87.     end;
  88.     Write(S3);              { write button status }
  89.  
  90.   until KeyPressed;
  91.  
  92. end; {TestMouse}
  93.  
  94.  
  95. begin {Main}
  96.  
  97.   DirectVideo := false;
  98.  
  99.   grDriver := EGA;
  100.   grMode := EGAHi;                   { sets EGA 16 color 640 x 350 mode }
  101.   InitGraph(grDriver, grMode, '');
  102.   if GraphResult<> grOk then
  103.   begin
  104.      Writeln('Graphics init error: ', GraphErrorMsg(grDriver));
  105.      Halt(1);                        { if error during graphics mode }
  106.   end;                               { initialization then abort }
  107.  
  108.   TestMouse;
  109.  
  110.   CloseGraph;
  111.  
  112.   RestoreCrtMode;
  113.  
  114. end.
  115.